package com.shenzhen.horselive;


import java.util.HashMap;

/**
 * Created by lu on 2016/11/23.
 */

public class Cache {

    private HashMap<Object, Object> mCache = new HashMap<>();

    public static Cache get() {
        return App.getInstance().getCache();
    }

    public void cache(String key, Object value) {
        mCache.put(key, value);
    }
    public void cache(Object key, Object value) {
        mCache.put(key, value);
    }


    public int getInt(String key, int defaultValue) {
        Integer value = (Integer) mCache.get(key);
        return value != null ? value : defaultValue;
    }

    public boolean getBoolean(String key, boolean defaultValue) {
        Boolean value = (Boolean) mCache.get(key);
        return value != null ? value : defaultValue;
    }

    public String getString(String key) {
        return (String) mCache.get(key);
    }

    public Object getCache(String key) {
        return mCache.get(key);
    }

    public Object popCache(Object key) {
        return mCache.remove(key);
    }


    public void clear() {
        mCache.clear();
    }
}
